<#assign base=request.contextPath />
<!DOCTYPE html>
<html>
<head>
  <base href="${base}">	
  <meta charset="utf-8">
  <title>配置信息</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="${base}/layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="${base}/layuiadmin/style/admin.css" media="all">
  <link rel="stylesheet" href="${base}/css/my.css" media="all">
  <style>
  	.layui-form-label {
  		 width: 120px;
  	}
  	.layui-input-block {
  		 margin-left: 150px;
  	}
  </style>
</head>

<body>
	<div id="app" class="layui-fluid">
		<div class="layui-card">
			<div id="search-form" class="layui-form one layui-card-header layuiadmin-card-header-auto">
					<div class="layui-form-item">
			    		<label class="layui-form-label required">翻译接口URL</label>
			    		<div class="layui-input-block">
			      			<input type="text" name="cnf.translate_url" lay-verify="required" autocomplete="off" class="layui-input">
			    		</div>
			    	</div>
			  		
			  		<div class="layui-form-item">
    					<div class="layui-input-block" style="margin-left:150px">
					      	<button class="layui-btn" lay-submit lay-filter="myform">
					      	<i class="layui-icon layui-icon-ok"></i> 保 存</button>
    					</div>
  					</div>	  		
		  	</div>
		</div>
	</div>
  	
  	<script src="${base}/js/lib/jquery-1.11.3.min.js"></script>
	<script src="${base}/js/commons.js"></script>
  	<script src="${base}/layuiadmin/layui/layui.js"></script>
  	<script>
  	//获得表单并填充
  	layui.config({
    	base: '${base}/layuiadmin/' //静态资源所在路径
  	}).extend({
    	index: 'lib/index'
  	}).use(['index', 'form'], function(){
  		var $ = layui.$;
    	var form = layui.form;
    	var layer = layui.layer;
    	
    	//监听提交
    	form.on('submit(myform)', function(data){
    	    $$.ajax({
    	    	url: '${base}/system/config/save',
    	    	data: data.field,
    	    	callback: function(data) {
    	    		if(data.success) {
    	    			layer.msg('保存成功！', {icon: 1});
    	    		}    	    		
    	    	}
    	    });
    	    return false;
    	});
    	
    	//加载表单
    	$$.ajax({
    	    url: '${base}/system/config/find',
    	    callback: function(json) {
    	    	$(':input[name^=cnf]').each(function() {
    	    		var name = $(this).attr('name');
    	    		if(name.indexOf('cnf.') == 0) {
    	    			name = name.substring(4);
    	    			$(this).val(json.data[name]);	
    	    		}
    	    	});
    	    }    	    
    	});

  	});
  </script>
</body>
</html>
